
<template>
  <div class="ChoutOut">
    <div class="Cho-l">
       <InfoCar :CarListInfo='CarListInfo' class="stang-l-bed"></InfoCar>
<!--       <InfoCar :CarListInfo='CarListDate'></InfoCar>-->
      <ReportCar :xamReportList="xamReportList" @labtestReport="FoxMessage"></ReportCar>
    </div>
    <div class="Cho-r">
      <InfoTit title="检验报告"></InfoTit>
      <div class="pro-details">
        <div class="pro-col">
          <div class="pro-col-r">
            <span>姓名:</span>
            <span>{{personal.pa_name}}</span>
          </div>
          <div class="pro-col-r">
            <span>科别:</span>
            <span>{{personal.in_dpname}}</span>
          </div>
          <div class="pro-col-r">
            <span>标本号:</span>
            <span>{{firstReport.specimen_id}}</span>
          </div>
        </div>
        <div class="pro-col">
          <div class="pro-col-r">
            <span>病历号 :</span>
            <span>{{personal.case_number}}</span>
          </div>
          <div class="pro-col-r">
            <span>病区 :</span>
            <span>{{personal.in_dpname}}</span>
          </div>
          <div class="pro-col-r">
            <span>标本类型:</span>
            <span>{{firstReport.labtest_type}}</span>
          </div>
        </div>
        <div class="pro-col">
          <div class="pro-col-r">
            <span>性别:</span>
            <span>{{personal.sex_name}}</span>
          </div>
          <div class="pro-col-r">
            <span>床号:</span>
            <span>{{personal.bed_no}}</span>
          </div>
          <div class="pro-col-r">
            <span>送检日期:</span>
            <span>{{firstReport.inspec_date}}</span>
          </div>
        </div>
        <div class="pro-col">
          <div class="pro-col-r">
            <span>年龄:</span>
            <span>{{personal.pa_age1}}</span>
          </div>
          <div class="pro-col-r">
            <span>送检医生:</span>
            <span>{{firstReport.inspec_doctor_name}}</span>
          </div>
        </div>
      </div>
      <div class="check-tab">
        <table border="1" cellspacing="0" cellpadding="0" style="">
          <thead>
            <tr>
              <td>项目编码</td>
              <td>名称</td>
              <td>结果</td>
              <td>单位</td>
              <td>参考值</td>
            </tr>
          </thead>
          <tbody class="tbody">
            <tr v-for="(item, index) in AllDetail" :key="index">
              <th>{{item.item_code}}</th>
              <th>{{item.item_name}}</th>
              <th>{{item.result}}</th>
              <th>{{item.units}}</th>
              <th>{{item.re_value}}</th>
            </tr>
          </tbody>
        </table>
      </div>
    </div>
  </div>
</template>

<script>
import ReportCar from '../common/ReportCar'
import InfoCar from '../common/InfoCar'
import InfoTit from '../common/InfoTit'
import axios from 'axios'
import urls from '../../common'
export default {
  name: 'ChoutOut',
  components: {
    ReportCar,
    InfoCar,
    InfoTit
  },
  data () {
    return {
      CarListInfo: {
        src: require('../../img/wardR/chest-icon.png'),
        InfoTit: this.$store.state.personinfo.belong_dpname,
        decide: true,
        bgImg: require('../../img/wardR/aid-bg.png'),
        boxS: '-.1rem -.1rem .3rem 0 #d5e9e6',
        InfoCon: this.$store.state.bedNo
      },
      CarListDate: {
        src: require('../../img/wardR/chest-icon.png'),
        InfoTit: '急救中心',
        decide: false,
        bgImg: require('../../img/wardR/present-bg.png'),
        boxS: '-.1rem -.1rem .3rem 0 #d5e9e6',
        InfoCon: this.$store.state.bedNo
      },
      reportList: [],
      firstReport: {},
      JsonApplyTime: {},
      AllDetail: [],
      xamReportList: [],
      personal: {}
    }
  },
  methods: {
    basicInfo (bed) {
      axios.get(urls.examReportBasic + '/' + bed)
        .then((res) => {
          if (res.data.code === '200') {
            this.personal = res.data.data
            this.labtestReportInfo(this.personal.pa_id, this.personal.in_time)
          }
        })
    },
    labtestReportInfo (id, intime) {
      const Qs = require('qs')
      axios.post(urls.labtestReportInfo, Qs.stringify({paId: id, inTime: intime}),
        {
          headers: {
            'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8'
          }
        }
      ).then((res) => {
        if (res.data.code === '200') {
          this.xamReportList = res.data.data
          if (res.data.data.length === 0) {
          } else {
            this.labtestReportDetail(this.xamReportList[0].apply_id)
          }
        }
      })
    },
    labtestReportDetail (applyId) {
      const Qs = require('qs')
      axios.post(urls.labtestReportDetail, Qs.stringify({applyId: applyId}),
        {
          headers: {
            'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8'
          }
        }
      ).then((res) => {
        if (res.data.code === '200') {
          this.AllDetail = res.data.data
          this.firstReport = res.data.data[0]
        }
      })
    },
    /* labtestReportInfo (bed) {
      axios.get(urls.labtestReportInfo + '/' + bed).then((res) => {
        if (res.data.code === '200') {
          this.reportList = res.data.data.list
          this.firstReport = res.data.data.list[0]
          console.log(this.reportList)
          this.labtestReportDetail()
        }
      })
    },
    labtestReportDetail () {
      let len = this.reportList.length
      for (let i = 0; i < len; i++) {
        // console.log(this.reportList[i].apply_id)
        // let addd = this.reportList[i].apply_id
        this.JsonApplyTime[this.reportList[i].apply_id] = this.reportList[i].in_time
      }
      this.JsonApplyTime = JSON.stringify(this.JsonApplyTime)
      axios.post(urls.labtestReportAllDetail, JSON.parse(this.JsonApplyTime))
        .then((res) => {
          if (res.data.code === '200') {
            let AllDetailList = res.data.data
            let Obj = Object.keys(AllDetailList)
            let len = Obj.length
            for (let i = 0; i < len; i++) {
              this.AllDetail.push(...AllDetailList[Obj[i]])
            }
            console.log(this.AllDetail)
          }
        })
    }, */
    FoxMessage (applyId) {
      this.labtestReportDetail(applyId)
    },
    Receiver (applyId, inTime) {
      console.log(applyId, inTime)
      // this.labtestReportDetail(applyId, inTime)
    }
  },
  mounted () {
    this.basicInfo(this.$store.state.bedNo)
    // this.labtestReportInfo(this.$store.state.bedNo)
    // this.labtestReportDetail()
  }
}
</script>

<style style="stylus" scoped>
  .ChoutOut{
    display: flex;
  }
  .ChoutOut .Cho-l{
    padding-left: .2rem;
  }
  .ChoutOut .Cho-l .stang-l-bed{
     margin-bottom: .1rem;
  }
  .ChoutOut .Cho-r{
    flex: 1;
    margin: 0 .3rem;
    padding: 0 .2rem;
    background-color: #fff;
    border-radius: 0.1rem;
    box-shadow: 0px 0.11rem 0.24rem 0px rgba(127, 135, 143, 0.1);
  }
  .ChoutOut .Cho-r .pro-details{
    display: flex;
    justify-content: space-between;
  }
  .ChoutOut .Cho-r .pro-col .pro-col-r{
    margin-bottom: .38rem;
  }
  .ChoutOut .Cho-r .pro-col .pro-col-r:nth-child(2){
    margin-bottom: .6rem;
  }
  .ChoutOut .Cho-r .pro-col .pro-col-r>span:first-child{
     display: inline-block;
     max-width: 1.1rem;
     color: #7e92ab;
     font-size: 0.24rem;
  }
  .ChoutOut .Cho-r .pro-col .pro-col-r>span:last-child{
    color: #161d26;
    font-size: 0.24rem;
  }
  /* .ChoutOut .Cho-r .check-tab table{
    width: 100%;
    border: 1 solid #ccc;
    text-align: center;
    border-collapse: collapse;
  }
  .ChoutOut .Cho-r .check-tab table tr{
    height: .82rem;
    line-height: .82rem;
  } */
.ChoutOut .Cho-r table{
  width: 100%;
  text-align: center;
  font-size: .28rem;
  border: 1;
  border-collapse: collapse;
  border-width:0px;
  border-style:hidden
}
.ChoutOut .Cho-r table>thead{
  text-align: center;
  background-color: #fff;
  color: #161d26;
  height: .56rem;
  line-height: .56rem;
  display:table;
  width:100%;
  table-layout:fixed;
}
.ChoutOut .Cho-r .tbody{
  display: inline-block;
  height: 4.22rem;
  overflow-y:scroll;
  -webkit-overflow-scrolling: touch;
  border-collapse: collapse;
  border-width:0px;
  border-style:hidden
}
.ChoutOut .Cho-r .tbody th{
  font-weight: normal;
  font-size: 0.28rem;
  color: #1c1c1c;
  height: 0.8rem;
  line-height: 0.8rem;
}
.ChoutOut .Cho-r .tbody::-webkit-scrollbar {
  display: none;
}
.ChoutOut .Cho-r .tbody tr{
    display:table;
    width:100%;
    height: .58rem;
    table-layout:fixed;
    color: #6c7580;
    border: 1px solid #ccc;
  }
  .ChoutOut .Cho-r thead tr td{
    box-sizing: border-box;
    border: 1px solid #ccc;
    font-size: 0.28rem;
    height: 0.78rem;
    line-height: 0.78rem;
    color: #7e92ab;
  }
</style>
